// 路由文件

//Suspense：其是一个组件，负责去应用组件的以及可以制定懒加载时需要的提示组件
import {lazy,Suspense} from "react";
import {Route,Redirect,Switch} from "react-router-dom";

// 导入Loading组件(作为懒加载提示)
import Loading from "@/components/Loading"

// 导入懒加载需要使用的组件
const Home = lazy(()=>import("../views/home/Home.jsx"));
const Chat = lazy(()=>import("../views/chat/Chat.jsx"));
const Login = lazy(()=>import("../views/login/Login.jsx"));
const Shopping = lazy(()=>import("../views/shopping/Shopping.jsx"));


// 编写路由组件
const Routes=()=>{
	// fallback属性,用来显示加载提示
	return (
	<Suspense fallback={<Loading/>}>
				
				<Switch>
					 <Route path="/home" component={Home}></Route>
					 <Route path="/chat" component={Chat}></Route>
					 <Route path="/login" component={Login}></Route>
					 <Route path="/shopping" component={Shopping}></Route>
					 <Redirect from="/" to="/home" />
				</Switch>
			
	</Suspense>
	);
};

export default Routes;